<include file="../header" />
<style>
	.keyword-input{
		margin-top: 1rem;
	}
	.keyword-btn{
		margin-top: 0.5rem;
		width: 120px;
		float: left;
	}
	.kw-btn{
		width: 50px;
	}
	.shut-down{
		width: 12px;
		height: 12px;
		position: relative;
		left: -0.5rem;
		top: -0.9rem;
		cursor: pointer;
	}
</style>
<script type="text/javascript" src="/Template/js/vue.min.js"></script>
<body class="J_scroll_fixed" id="container">
<script type="text/javascript">
	$(function() {

		var app = new Vue({
			el: '#container',
			data: {
				keywordList: []
			},
			methods: {
				remove: function(index) {
					app.keywordList.splice(index,1);
				}
			}
		})

		$("a.add-keyword").bind("click", function() {

			var code = $(this).prev().find("input").val();
			var keyword = $(this).prev().prev().find("input").val();

			if(keyword == "") {
				alert("关键词不能为空");
				return false;
			}

			if(code == "") {
				alert("编码不能为空");
				return false;
			}

			var data = [];

			data.code = code;
			data.keyword = keyword;

			app.keywordList.push(data);

			$(this).prev().find("input").val("");
			$(this).prev().prev().find("input").val("");

		});

		var description = UE.getEditor('description',{
			initialFrameHeight:300,
			initialContent : "",
			serverUrl :'{:U("activity/ueditorUpload")}'
		});

		$("button#upload").click(function(){
			//上传文件
			$.ajaxFileUpload({
				url:"{:U('activity/uploadImage')}",//处理图片脚本
				secureuri :false,
				fileElementId :'fileToUpload',//file控件id
				dataType : 'json',
				success : function (data, status){
					$("input[name=imageUrl]").val(data);
					$("img[name=preShow]").attr("src", data);
				},
				error: function(data, status, e){
					alert(e);
				}
			})
		});

        $("button.btn_submit").click(function() {
            $("input[name=description]").val(description.getContent());
            $("form").submit();

        });

		if("{$info.faq_class_id}" == 1 || "{$info.faq_class_id}" == 6 ) {
            $(".imgUrl").show();
            $(".answer").hide();

		} else {
            $(".answer").show();
            $(".imgUrl").hide();
		}

        $("select[name=faqClassId]").change(function() {
            if($(this).val() == 1 || $(this).val() == 6) {
                $(".imgUrl").show();
                $(".answer").hide();
            } else {
                $(".answer").show();
                $(".imgUrl").hide();
            }
        });
	})

</script>
<script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.all.min.js"></script>
<div class="wrap jj">
	<div class="common-form">
		<form method="post" class="form-horizontal J_ajaxForm" action="{:U('clubfoot/faqEditPost')}">
			<fieldset>
				<input type="hidden" name="id" value="{$info.faq_id}" />
				<div class="control-group">
					<label class="control-label">分类：</label>
					<div class="controls">
						<select name="faqClassId">
							{:getFaqClassSelectOptionHtml($info['faq_class_id'], 0)}
						</select>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">标题：</label>
					<div class="controls">
						<input type="text" style="width: 40rem;" class="input" name="name" value="{$info.name}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">问题：</label>
					<div class="controls">
						<textarea style="height:5rem; width: 40rem;" name="question">{$info.question}</textarea>
					</div>
				</div>
				<div class="answer" style="display: none;">
					<div class="control-group">
						<label class="control-label">解答：</label>
						<div class="controls">
							<textarea style="height:15rem; width: 40rem;" name="answer">{$info.answer}</textarea>
						</div>
					</div>
				</div>
				<div class="imgUrl">
					<div class="control-group">
						<label class="control-label">视频图片:</label>
						<div class="controls">
							<input id="fileToUpload" type="file" name="fileToUpload" style="width:170px;">
							<button type="button" class="btn btn-primary" id="upload">上传</button>
							<input type="hidden" name="imageUrl" value="{$info.image_url}"/>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">图片预览:</label>
						<div class="controls">
							<img src="{$info.image_url}" name="preShow" style="width:250px;height:150px;" />
							<div class="delete"></div>
						</div>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">详情描述：</label>
					<div class="controls">
						<input type="hidden" name="description" />
						<script type="text/plain" id="description" name="description" {$info.detail}></script>
					</div>
				</div>
			</fieldset>

			<div class="form-actions">
				<button type="button" class="btn btn-primary btn_submit">更新</button>
				<a class="btn" href="{:U('clubfoot/faq')}">返回</a>
			</div>
		</form>
	</div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>